<?php


    //定义的变量
    //1.获取前端数据
    $username=$_POST['username'];
    $password=$_POST['password'];

    $con=mysqli_connect('localhost','root','root','test');
    //var_dump($con);
    if($con){
        mysqli_query($con,'set name utf8');
        $sql="select * from login where username='$username' and password='$password'";
        $res=mysqli_query($con,$sql);
        //-> 是获取 $res对象的属性
        if($res->num_rows>0){
            // $arr=mysqli_fetch_all($res,MYSQLI_ASSOC);
            // print_r($arr);
            echo '登录成功';
        }else{
            echo '登录失败';
        }

    }else{
        echo '连接数据库失败';
    }
    mysqli_close($con);


?>